import grails.test.*

class JankenServiceTests extends GrailsUnitTestCase {
    def jankenService
    protected void setUp() {
        super.setUp()
        jankenService = new JankenService()
    }

    protected void tearDown() {
        super.tearDown()
        jankenService = null
    }

    void testFair() {
        assert 0 == jankenService.fair(Janken.STONE,Janken.STONE)
        assert 0 == jankenService.fair(Janken.PAPER,Janken.PAPER)
        assert 0 == jankenService.fair(Janken.SCISSORS,Janken.SCISSORS)

        assert -1 == jankenService.fair(Janken.SCISSORS,Janken.PAPER)
        assert -1 == jankenService.fair(Janken.PAPER,Janken.STONE)
        assert -1 == jankenService.fair(Janken.STONE,Janken.SCISSORS)

        assert 1 == jankenService.fair(Janken.PAPER,Janken.SCISSORS)
        assert 1 == jankenService.fair(Janken.STONE,Janken.PAPER)
        assert 1 == jankenService.fair(Janken.SCISSORS,Janken.STONE)
    }

    void testPlay() {
        assert !jankenService.play(Janken.SCISSORS,Janken.PAPER)
        assert !jankenService.gameOver
        assert !jankenService.play(Janken.PAPER,Janken.SCISSORS)
        assert !jankenService.gameOver
        assert "player" == jankenService.play(Janken.STONE,Janken.SCISSORS)
        assert jankenService.gameOver
    }
}
